set grabbedCastNo to the memberNum of sprite spriteNo
set grabbedCastLocV to the locV of sprite spriteNo
set grabbedCastLocH to the locH of sprite spriteNo
if the name of member the memberNum of sprite spriteNo = (grabbedCastLocH && grabbedCastLocV) then
exit
end if
set locHOffset to the mouseH - grabbedCastLocH
set locVOffset to the mouseV - grabbedCastLocV
if spriteNo < lastPieceNo then
repeat with spriteNo = spriteNo to lastPieceNo - 1
set nextSpriteNo to spriteNo + 1
set the memberNum of sprite spriteNo to the memberNum of sprite nextSpriteNo
set the locV of sprite spriteNo to the locV of sprite nextSpriteNo
set the locH of sprite spriteNo to the locH of sprite nextSpriteNo
end repeat
set the memberNum of sprite lastPieceNo to grabbedCastNo
set the locV of sprite lastPieceNo to grabbedCastLocV
set the locH of sprite lastPieceNo to grabbedCastLocH
end if
repeat while the mouseDown
set the locV of sprite lastPieceNo to max(120, the mouseV - locVOffset)
set the locH of sprite lastPieceNo to the mouseH - locHOffset
updateStage()
end repeat
set testLoc to the name of member the memberNum of sprite lastPieceNo
if (abs(the locH of sprite lastPieceNo - value(word 1 of testLoc)) < 10) and (abs(the locV of sprite lastPieceNo - value(word 2 of testLoc)) < 10) then
puppetSound("jigsaw Piece")
set the locH of sprite lastPieceNo to value(word 1 of testLoc)
set the locV of sprite lastPieceNo to value(word 2 of testLoc)
set PUZZLEPIECESDONE to 1 + PUZZLEPIECESDONE
updateStage()
if PUZZLEPIECESDONE = (lastPieceNo - firstPieceNo + 1) then